package yi.commons.exceptions;

/**
 * 通用异常类，带错误码和错误消息
 *
 * @author wangda
 * @date 2020-10-13
 */
public class CommonException extends RuntimeException{
    /** 错误码，根据具体的业务设置 */
    protected String errorCode;

    /** 代码描述，具体的错误信息在RuntimeException的Message中 */
    protected String errorDesc;

    public CommonException(String message) {
        super(message);
    }

    public CommonException(Throwable throwable) {
        super(throwable);
    }

    public CommonException(String message, Throwable throwable) {
        super(message, throwable);
    }

    public CommonException() {
        super();
    }

    public CommonException setErrorCode(String errorCode) {
        this.errorCode = errorCode;
        return this;
    }

    public CommonException setErrorDesc(String errorDesc) {
        this.errorDesc = errorDesc;
        return this;
    }

    public CommonException setErrorCode(String errorCode, String errorDesc) {
        this.errorCode = errorCode;
        this.errorDesc = errorDesc;
        return this;
    }

    public String getErrorCode() {
        return this.errorCode;
    }

    public String getErrorDesc() {
        return this.errorDesc;
    }

}
